home *** CD-ROM | disk | FTP | other *** search
- Path: qualcomm.com!usenet
- From: nabbasi@qualcomm.com (Nasser Abbasi)
- Newsgroups: comp.lang.c++
- Subject: Re: Is there a tool for exception-checking?
- Date: 9 Feb 1996 10:30:09 GMT
- Organization: QUalcomm Inc.
- Message-ID: <4ff7nh$epm@qualcomm.com>
- References: <311B1359.41B1@ids-scheer.de>
- NNTP-Posting-Host: annex-p26.qualcomm.com
- X-Newsreader: WinVN 0.90.4
-
- In article <311B1359.41B1@ids-scheer.de>, Thomas Trenz <trenz@ids-scheer.de> says:
- >
- >Hi folks,
- >
- >Is there a tool, that can check a projects throw-statements.
- >For example:
- >
- >class A
- >{
- >public:
- >
- > int f () throw (B, C);
- > int g () throw (B);
- >};
- >
- >
- >int A :: f () throw (B, C)
- >{
- > // some code that can throw either B or C...
- >}
- >
- >int A :: g () throw (B)
- >{
- > f();
- >}
- >
- >
- >Raising an exception of type C in f() causes an runtime-
- >error in g(), because g guarantees, that it only raises
- >exceptions of type B.
- >
- >So is there any tool, that can find these pitfalls?
- >
- >Thanx in advance...
- >
-
- First , I do not know of any such tool myself.
-
- I have not used C++ exceptions much (compiler we use do not support
- them for the target we have), but it seems to me that no tool
- really is needed here.
-
- A function will raise the SUM of the following exceptions:
- 1. all possible exceptions it raises itself.
- 2. all possible exceptions raised by each function call inside it.
-
- Item 1 above is easy to find , since you are writing that function, or
- can be found by searching for all throw statments in the function.
-
- Item 2 can by found by making a list that contains each function
- called from that function, then getting the defintion of that
- function to see what exceptions the function can raise, and by
- the magic of cut/paste you have the list of total exceptions needed.
-
- The only problem I see here (which is why you probably asked the question)
- is that one might miss locating all function calls made by just doing
- visual inspection in the code. Have you tried to look at the compiler
- listing file, some compilers can generate listing showing symbols
- referenced in each function, and type of symbole. This might help.
- But it seems to me just looking and the code should be enough.
-
- After rambling all of this, I am not sure now I was of any help to you.
-
- Nasser
-